#254 通过web应用查看日志

from flask import Flask, render_template,request,escape
app=Flask(__name__)
@app.route("/viewLog")
def view_the_log()->str:
    #打开文件流并赋值给logStream变量
    with open('vsearch.log') as logStream:
        contents = logStream.read()
        #获取地址传参（get参数），比如url == ?isEsc=true
        isEscap = request.args.get('isEsc')
        if(isEscap=='true'):
            contents= escape(contents)
    return contents
##restful传参
@app.route("/viewLog/<isEsc>")
def view_the_log2(isEsc)->str:
    #打开文件流并赋值给logStream变量
    with open('vsearch.log') as logStream:
        contents = logStream.read()
    return escape(contents)


if(__name__=='__main__'):
    app.run(debug=True)


##page 259